home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_hexeditroutine.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  105 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <intuition/sghooks.h>    /* For struct SGWork */
  17.  
  18. /*****************************************************************************/
  19.  
  20. #include "Assert.h"
  21.  
  22. /*****************************************************************************/
  23.  
  24. #ifdef DO_HEXHOOK    /* Support code */
  25.  
  26. ULONG SAVE_DS ASM
  27. LTP_HexEditRoutine(REG(a0) struct Hook *hook,REG(a2) struct SGWork *sgw,REG(a1) Msg msg)
  28. {
  29.     LayoutHandle *handle;
  30.     ObjectNode *node;
  31.     BOOL activate;
  32.  
  33.     switch(msg->MethodID)
  34.     {
  35.         case SGH_KEY:
  36.  
  37.             handle = hook->h_Data;
  38.  
  39.             if(sgw->IEvent->ie_Code == 0x5F && handle->HelpHook)
  40.             {
  41.                 sgw->Code        = 0x5F;
  42.                 sgw->Actions    = (sgw->Actions & ~SGA_BEEP) | SGA_END | SGA_USE;
  43.  
  44.                 LTP_AddHistory(sgw);
  45.  
  46.                 break;
  47.             }
  48.  
  49.             if(sgw->IEvent->ie_Code == CURSORUP || sgw->IEvent->ie_Code == CURSORDOWN)
  50.                 LTP_HandleHistory(sgw);
  51.  
  52.             activate = TRUE;
  53.  
  54.             if(GETOBJECT(sgw->Gadget,node))
  55.             {
  56.                 if(node->Type == INTEGER_KIND)
  57.                 {
  58.                     if(node->Special.Integer.LastGadget)
  59.                         activate = FALSE;
  60.  
  61.                     if(!LTP_ConvertNum((node->Min < 0),sgw->WorkBuffer,(LONG *)&sgw->StringInfo->LongInt))
  62.                     {
  63.                         sgw->EditOp        = EO_BADFORMAT;
  64.                         sgw->Actions    = SGA_BEEP;
  65.                     }
  66.  
  67.                     if(node->Special.Integer.ValidateHook)
  68.                     {
  69.                         if(!CallHookPkt(node->Special.Integer.ValidateHook,sgw,msg))
  70.                         {
  71.                             sgw->EditOp        = EO_BADFORMAT;
  72.                             sgw->Actions    = SGA_BEEP;
  73.                         }
  74.                     }
  75.                 }
  76.             }
  77.  
  78.             if(sgw->EditOp == EO_ENTER && !(sgw->IEvent->ie_Qualifier & QUALIFIER_SHIFT))
  79.             {
  80.                 if(activate && handle->AutoActivate)
  81.                     sgw->Actions |= SGA_NEXTACTIVE;
  82.  
  83.                 if(!(sgw->Actions & SGA_NEXTACTIVE))
  84.                     sgw->Code = '\r';
  85.             }
  86.  
  87.             if(sgw->Actions & SGA_END)
  88.                 LTP_AddHistory(sgw);
  89.  
  90.             /* Falls through to... */
  91.  
  92.         case SGH_CLICK:
  93.  
  94.             break;
  95.  
  96.         default:
  97.  
  98.             return(FALSE);
  99.     }
  100.  
  101.     return(TRUE);
  102. }
  103.  
  104. #endif    /* DO_HEXHOOK */
  105.